@extends('public.admin.layout')
@section('header')
<section class="content-header">
        <h1>
                小说分卷管理
            <small>Preview of UI elements</small>
        </h1>
        <ol class="breadcrumb">
            <li><a href="{{route('admin.novel')}}"><i class="fa fa-dashboard"></i> 所有小说</a></li>
            <li><a href="#">小说分卷管理</a></li>
        </ol>
    </section>
@endsection
 
@section('content')
<div class="row">
        <div class="col-sm-12">
                <button type="button" class="btn  btn-primary btn-sm" data-toggle="modal" data-target="#addModal">
                        新增
                </button>
            <table id="example2" class="table table-bordered table-hover dataTable" role="grid" >
                <thead>
                    <tr role="row">
                       
                            <th>分卷 ID</th>
                            <th>分卷名称</th>
                            <th>所属小说</th>
                            <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    @foreach($vols as $vol)
                    <tr role="row" class="data-row">
                
                            <td>{{$vol->id}}</td>
											<td class="volname">{{$vol->volname}}</td>
											<td class="novelname">{{$vol->novel->novelname}}</td>
                                            <td><button type="button" class="btn  btn-primary btn-sm" data-toggle="modal" data-target="#editModal">
                                                    编辑
                                            </button><button type="button" class="btn btn-warning btn-sm ml5" data-toggle="modal" data-target="#deleteModal">
                                                    删除
                                            </button>
                                            </td>
                    </tr>
                    @endforeach
    
                </tbody>
            </table>
            
            {{$vols->links()}}
        </div>
    </div>
    @if (isset($vol))
    @component('public.modal') @slot('modalId') editModal @endslot @slot('modalTitle') 编辑分卷 @endslot @slot('actionUrl') {{route('admin.vol.edit',['id'=>$vol->id])}}
    @endslot
        @include('admin.vol.form')
     @endcomponent
     @component('public.modal') @slot('modalId') deleteModal @endslot
     @slot('modalTitle') 删除分卷 @endslot @slot('actionUrl') {{route('admin.vol.destroy',['id'=>$vol->id])}} @endslot 
         @component('public.message')
             确定要删除该分卷吗？ 
         @endcomponent 
     @endcomponent 
     @endif
     @component('public.modal') @slot('modalId') addModal @endslot @slot('modalTitle') 新增分卷 @endslot @slot('actionUrl') {{route('admin.vol.add',['id'=>Request()->id])}}
    @endslot
    @slot('method')
        POST
    @endslot
        @include('admin.vol.form')
     @endcomponent  
     
         
    
    

@endsection
@section('script')
<script>
    $('#editModal').on('show.bs.modal',function(event){
              var button=$(event.relatedTarget)
              var id=button.data('id')
              var row=button.closest('.data-row')
              var name=row.children('.volname').text()
              $('#volname').val(name)
         
          })

</script>
@endsection